<template>
  <div>
    <el-row :gutter="15">
      <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
        <el-col :span="11">
          <el-form-item label="list1" prop="list1">
            <el-input v-model="formData.list1" type="textarea" placeholder="请输入list1" rows="15" style="weight:75%;"
                      :autosize="{minRows: 15, maxRows: 15}" :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="list2" prop="list2">
            <el-input v-model="formData.list2" type="textarea" placeholder="请输入list2" rows="15" style="weight:75%;"
                      :autosize="{minRows: 15, maxRows: 15}" :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="以1为基准" prop="result1">
            <el-input v-model="formData.result1" type="textarea" placeholder="比较结果1" rows="15" style="weight:75%;"
                      :autosize="{minRows: 7, maxRows: 150}" :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="以2为基准" prop="result2">
            <el-input v-model="formData.result2" type="textarea" placeholder="比较结果2" rows="15" style="weight:75%;"
                      :autosize="{minRows: 7, maxRows: 150}" :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item>
            <el-button size="medium" type="primary" @click="submitForm">提交</el-button>
            <el-button @click="resetForm">重置</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>
  </div>
</template>
<script>
    import {mapGetters} from 'vuex'
    import {getToken} from '@/utils/auth'
    import checkPermission from '@/utils/permission'
    import initData from '@/mixins/initData'
    import {parseTime, downloadFile} from '@/utils/index'
    import {compareDifferentFromList} from '@/api/code-tools'
    import {downloadFileFunction} from '@/api/downloadFile'

    export default {
        components: {},
        props: [],
        data() {
            return {
                formData: {
                    list1: '',
                    list2: '',
                    type: 'list1',
                    result1: '',
                    result2: ''
                },
                rules: {
                    list1: [{
                        required: true,
                        message: '请输入list1',
                        trigger: 'blur'
                    }],
                    list2: [{
                        required: true,
                        message: '请输入list2',
                        trigger: 'blur'
                    }],
                },
                typeOptions: [{
                    "label": "以list1为基准",
                    "value": "list1"
                }, {
                    "label": "以list2为基准",
                    "value": "list2"
                }],
            }
        },
        computed: {},
        watch: {},
        created() {
        },
        mounted() {
        },
        methods: {
            submitForm() {
                this.$refs['elForm'].validate(valid => {
                    if (!valid) return;
                    const list1 = this.formData.list1;
                    const list2 = this.formData.list2;
                    let params = {
                        list1: list1,
                        list2: list2
                    };
                    compareDifferentFromList(params).then(res => {
                        this.formData.result1 = res.data.result1;
                        this.formData.result2 = res.data.result2;
                        console.log(res.data);
                        console.log(this.formData.result);
                        this.$notify({
                            title: '处理成功',
                            type: 'success',
                            duration: 2500
                        })
                    }).catch(err => {
                        console.log(err);
                    });
                })
            },
            resetForm() {
                this.$refs['elForm'].resetFields()
            },
        }
    }

</script>
<style>
</style>
